<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<%-- CSS Style Declarations --%>
	<link rel ="stylesheet" type="text/css" href="stylesheets/style.css" ></link>
	
	<%-- Java imports --%>
	<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
	<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
	<%@ page import="com.google.appengine.api.blobstore.BlobKey" %>
	<%@ page import="com.google.appengine.api.images.Image" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
	<%@ page import="com.google.appengine.api.datastore.Entity" %>
	<%@ page import="com.google.appengine.api.datastore.PreparedQuery" %>
	<%@ page import="com.google.appengine.api.datastore.Query" %>

	<%@ page import="com.google.appengine.api.images.ImagesService" %>
	<%@ page import="com.google.appengine.api.images.ImagesServiceFactory" %>
	
	<%-- Get reference to Java Objects --%>
	<% 
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	ImagesService imageService = ImagesServiceFactory.getImagesService();
	BlobKey blobKey = (BlobKey) request.getSession().getAttribute("blobKey");
 	%>
	
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Edit photo</title>
</head>

<body>

<div id="center-wrapper">
<div id="center-column">

<!-- Header -->
<div id="header">
<FORM action="tomain" method="post">
			<input
				type="submit"
				name="button1"
				class="headerbutton"
				value="Main Menu"
				title="">
</FORM>
</div> <!-- header -->


<!-- Page Title -->
<div style="
	font-size:30px;
	width: 600px;
	text-align:center;
	position:absolute;
	top:50px;
	">
	Edit Photo
</div> <!-- page title -->

<!-- Upload Form -->

<div style="
	position:absolute;
	top:140px;
	left:80px;
	width:600px;
	text-align:left;
	">
<%	
		String url = imageService.getServingUrl(blobKey,100,false);
		out.println("<img src=\"" + url + "\" />");
%>
<form action="/editphoto" method="post">
	Title: <input type="text" name="title"><br>
	Date: <input type="text" name="date"><br>
	<input type="submit" value="Submit">
</form>
	
</div>	

<!-- Message -->
<div style="
	position:absolute;
	top: 370px;
	width: 600px;
	text-align:center;
	">
	<% out.println(request.getSession().getAttribute("message")); %>
</div> <!-- message -->

</div> <!-- center-column -->
</div> <!-- center-wrapper -->
</body>
</html>